import Vue from 'vue'
import Vuex from 'vuex'
Vue.use(Vuex)
const state = {
  tip: {
    text: '',
    time: 1800,
    callback: null
  },
  loading: {
    visible: false,
    callback: null
  }
}
const actions = {
  setTip ({commit}, tip) {
    if (!tip.time) tip.time = 1800
    commit('SET_TIP', tip)
  },
  setLoading ({commit}, loading) {
    commit('SET_LOADING', loading)
  }
}
const mutations = {
  SET_TIP(state, tip) {
    state.tip = tip
  },
  SET_LOADING(state, loading) {
    state.loading = loading
  }
}
export default new Vuex.Store({
  state,
  actions,
  mutations
})

